<template>
	<view class="container">
		<uni-section title="食物轮播图展示" sub-title="" type="line">
			<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
				<swiper-item v-for="i in swiperlist">
					<view class="swiper-item">
						<image :src="'http://localhost:8090'+i.icon" mode=""></image>
					</view>
				</swiper-item>
			</swiper>
		</uni-section>
		<uni-section title="食物类别宫格展示" sub-title="" type="line">
			<uni-grid :column="3">
				<uni-grid-item v-for="l in foodlist">
					<view class="view_image" @click="foodfone(l.id)">
						<image :src="'http://localhost:8090'+l.icon" mode="aspectFit">
						</image>
						<text>{{l.typename}}</text>
					</view>


				</uni-grid-item>
			</uni-grid>
		</uni-section>
		<uni-section title="食物列表展示" sub-title="" type="line">
<uni-list>
	<uni-list-item v-for="(item,index) in showlist" clickable @click="showd(item.id)" :title="item.name"
	 :thumb="'http://localhost:8090'+item.icon" note="" :rightText="'￥'+item.price+'元'"></uni-list-item>
	
</uni-list>
		</uni-section>
		<uni-section title="食物评论列表展示" sub-title="" type="line">
			<uni-list>
				<uni-list-item v-for="(n,index) in commentlist" :title="n.comment" note=""></uni-list-item>
				
			</uni-list>
		</uni-section>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				swiperlist: [],
				foodlist: [],
				showlist:[],
				commentlist:[]
			}
		},
		methods: {
			foodfone(id){
				uni.navigateTo({
					url:'../foodgrid/foodgrid?id='+id
				})
			}
			
			
			,
showd(id){
	uni.navigateTo({
		url:'../fooddetail/fooddetail?id='+id
	})
}
		},
		onShow() {
			uni.request({
				url: 'http://localhost:8090/foodapp/foodSwiper/list',
				method: 'POST',
				data: {},
				success: res => {
					this.swiperlist = res.data.list
				},
				fail: () => {},
				complete: () => {}
			});
			uni.request({
				url: 'http://localhost:8090/foodapp/foodType/list',
				method: 'POST',
				data: {},
				success: res => {
					this.foodlist = res.data.list
				},
				fail: () => {},
				complete: () => {}
			});
			uni.request({
				url: 'http://localhost:8090/foodapp/food/list',
				method: 'POST',
				data: {},
				success: res => {console.log(res);
				this.showlist=res.data.list
				},
				fail: () => {},
				complete: () => {}
			});
			uni.request({
				url: 'http://localhost:8090/foodapp/comment/list',
				method: 'POST',
				data: {},
				success: res => {this.commentlist=res.data.list},
				fail: () => {},
				complete: () => {}
			});
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}

	.view_image {
		display: flex;
		flex: 1;
		flex-direction: column;
		text-align: center;
	}

	.view_image image {
		width: 100%;
		height: 100%;

	}
</style>
